package monitor.model.parameter;

import java.util.ArrayList;
import java.util.List;

/**
 * Stores list of obtained ECU parameters and Date of gathering.
 * Also contains Latitude and Longitude for car location.
 */
public class TimePoint {
	
	public static String DATE_MILLIS = "dateMillis"; 
	public static String LAT = "lat";
	public static String LNG = "lng";
	private long dateMillis;
	private double lat;
	private double lng;

	private List<EcuParameter> parameters = new ArrayList<EcuParameter>();

	public List<EcuParameter> getParameters() {
		return parameters;
	}

	public void setParameters(List<EcuParameter> parameters) {
		this.parameters = parameters;
	}

	public void addParameter(EcuParameter parameter) {
		this.parameters.add(parameter);
	}
	
	public long getDateMillis() {
		return dateMillis;
	}

	public void setDateMillis(long dateMillis) {
		this.dateMillis = dateMillis;
	}
	
	public double getLat() {
		return lat;
	}

	public void setLat(double lat) {
		this.lat = lat;
	}

	public double getLng() {
		return lng;
	}

	public void setLng(double lng) {
		this.lng = lng;
	}
	
	@Override
	public String toString() {
		StringBuilder json = new StringBuilder();
		json.append("{");
		json.append("\"" + DATE_MILLIS + "\":" + this.dateMillis +",");
		json.append("\"" + LAT + "\":" + this.lat +",");
		json.append("\"" + LNG + "\":" + this.lng +",");
		json.append("\"parameters\":");
		json.append("[");
		for (EcuParameter parameter : parameters) {
			json.append(parameter);
			json.append(",");
		}
		json.deleteCharAt(json.length() - 1);		
		json.append("]");
		
		json.append("}");
		return json.toString();
	}
	
}
